(self.webpackChunkmp_webgl = self.webpackChunkmp_webgl || []).push([
  [136],
  {
    76265: (i, t, e) => {
      "use strict";
      e.r(t),
        e.d(t, {
          ModelRatedMessage: () => o.E,
          SubmitModelRatingCommand: () => d.M,
          ToggleModelRatingDialogCommand: () => d.m,
          default: () => w,
        });
      var a = e(47724),
        s = e(88512),
        n = e(98811),
        o = e(62627),
        d = e(43229),
        r = e(89046),
        m = e(49080),
        g = e(38330);
      const l = new s.Z("model-rating-data-store"),
        h = (i) => i,
        c = (i) => i;
      class ModelRatingDataStore extends g.MU {
        constructor(i, t, e) {
          super({
            queue: i,
            deserialize: h,
            serialize: c,
            path: `${t}/api/v1/jsonstore/model/model-rating/${e}`,
          });
        }
        async canPromptRating() {
          let i;
          try {
            i = await this.read();
          } catch (i) {
            return (
              l.error("Failed to read existing rating data from JSONStore"), !1
            );
          }
          const t = !!i.rated_at;
          return !!!i.prompt_dismissed_at && !t;
        }
        async recordRatingSubmitted() {
          this.update({ rated_at: new Date().toISOString() });
        }
        async recordAutomaticPromptDismissed() {
          this.update({ prompt_dismissed_at: new Date().toISOString() });
        }
      }
      var u = e(38587);
      const p = new s.Z("rating-module");
      class ModelRatingModule extends a.Y {
        constructor() {
          super(...arguments),
            (this.name = "model-rating"),
            (this.totalActiveTime = 0),
            (this.wasLastOpeningAutomatic = !1),
            (this.handleActivityPingMessage = async (i) => {
              if (
                ((this.totalActiveTime +=
                  i.durationDollhouse + i.durationFloorplan + i.durationInside),
                this.totalActiveTime < 44500)
              )
                return;
              this.engine.unsubscribe(u.i, this.handleActivityPingMessage);
              (await this.store.canPromptRating()) &&
                !this.viewData.getIsDialogVisible() &&
                (this.engine.commandBinder.issueCommand(new d.m(!0)),
                (this.wasLastOpeningAutomatic = !0));
            }),
            (this.handleSubmitModelRatingCommand = async ({
              rating: i,
              didFinish: t,
            }) => {
              p.info(i),
                this.engine.broadcast(new o.E(i)),
                this.store.recordRatingSubmitted(),
                t &&
                  (this.engine.commandBinder.issueCommand(new d.m(!1)),
                  this.engine.commandBinder.issueCommand(
                    new r.Bz(m.P.RATING_THANK_YOU, !0)
                  ));
            }),
            (this.handleToggleDialogCommand = async ({ toVisible: i }) => {
              this.viewData.setDialogVisible(i);
              !this.viewData.getIsDialogVisible() &&
                this.wasLastOpeningAutomatic &&
                (this.store.recordAutomaticPromptDismissed(),
                (this.wasLastOpeningAutomatic = !1));
            });
        }
        async init(i, t) {
          (this.engine = t),
            (this.viewData = new n.P()),
            (this.store = new ModelRatingDataStore(
              i.queue,
              i.baseUrl,
              i.modelId
            )),
            this.bindings.push(
              t.commandBinder.addBinding(d.m, this.handleToggleDialogCommand),
              t.commandBinder.addBinding(
                d.M,
                this.handleSubmitModelRatingCommand
              ),
              t.subscribe(u.i, this.handleActivityPingMessage)
            ),
            t.market.register(this, n.P, this.viewData);
        }
        dispose(i) {
          this.bindings.forEach((i) => {
            i.cancel();
          }),
            (this.bindings = []),
            super.dispose(i);
        }
      }
      const w = ModelRatingModule;
    },
  },
]);
